package com.hassean.we.admin.common.Interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


    @Configuration
    public class MyWebAppConfigurer
            extends WebMvcConfigurerAdapter {
        //注入拦截器，其他的才能注入到拦截器中
        @Bean
        public ExceptionInterceptor exceptionInterceptor() {
            return new ExceptionInterceptor();
        }
        @Override
        public void addInterceptors(InterceptorRegistry registry) {

            // 多个拦截器组成一个拦截器链
            // addPathPatterns 用于添加拦截规则
            // excludePathPatterns 用户排除拦截

            registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**");
            //myInterceptor2()，不要new
            registry.addInterceptor( exceptionInterceptor()).addPathPatterns("/**");
            super.addInterceptors(registry);
        }

    }